import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_1_25_0/testWidget/custom_input_cell.dart';

class MyInputPage extends StatefulWidget {
  MyInputPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyInputPageState createState() => _MyInputPageState();
}

class _MyInputPageState extends State<MyInputPage> {
  String defaultFontFamily() {
    return !kIsWeb && defaultTargetPlatform == TargetPlatform.iOS ? 'PingFang SC' : '';
  }

  Widget _buildInput(
    BuildContext context,
  ) {
    // print('_buildInput: $inputBlankIndex');
    String initText = 'qrypgjv'; // qrypgjv
    TextEditingController _textController = TextEditingController.fromValue(TextEditingValue(
        // 设置内容
        text: initText,
        // 保持光标在最后
        selection: TextSelection.fromPosition(TextPosition(offset: initText.length))));
    // print('_buildInput_buildInput: $inputBlankIndex, ${widget.practiseInfo.id}');
    // FocusNode focusNode = FocusNode();
    // focusNode.addListener(() {
    //   print('焦点改变：$inputBlankIndex,${widget.practiseInfo.id}, ${focusNode.hasFocus}');
    //   // if (!focusNode.hasFocus) {
    //   //   dispatcher(UploadInputGapFillingAnswerAction());
    //   // }
    // });
    // String _focusKey = '${widget.practiseInfo.id}_$inputBlankIndex';
    // if (focusNodeMap[_focusKey] != null) {
    //   // focusNodeMap[_focusKey].dispose();
    // }
    // focusNodeMap[_focusKey] = focusNode;
    // test();
    return CustomInputCell.style1(
      controller: _textController,
      // focusNode: focusNode,
      // outDecoration: BoxDecoration(
      //   border: Border.all(color: CustomTheme.of(context).colors.borderColor),
      //   borderRadius: BorderRadius.circular(flexible(context, 4.0)),
      //   // color: Colors.green,
      // ),
      // customInputCellStyle: CustomInputCellStyle.style1,
      // cellHeight: 56,
      enable: true,
      onChanged: (String text) {},
      onSubmitted: (String text) {},
      decoration: CustomInputCell.decorationLarge,
      style:
          TextStyle(fontFamily: 'Microsoft Yahei', height: 1.3, textBaseline: TextBaseline.alphabetic, fontSize: flexible(context, 18.0), color: Colors.black),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          width: flexible(context, 180.0),
          // height: flexible(context, 33.0),
          child: Column(
            children: [
              Text(
                'This is a known issue in the current text measurement/rendering stack (ellipsis doesn work well with multi-line text and maxLines). Theres a newer implementation thats still experimental and incomplete. This issue doesnt exist in the new implementation.在写文字内容占大篇幅的页面是,总是会面临着改变字体的需求在写文字内容占大篇幅的页面是,总是会面临着改变字体的需求',
                style: TextStyle(height: 1.3, fontSize: flexible(context, 18.0), color: Colors.black),
              ),
              SizedBox(
                height: 10.0,
              ),
              _buildInput(context),
            ],
          ),
        ),
      ),
    );
  }
}
